package com.atguigu.bigdata.spark.sql;

import org.apache.spark.SparkConf;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class Spark04_SparkSQL_JDBC_JAVA {
    public static void main(String[] args) {
        // TODO 准备环境
        SparkConf conf = new  SparkConf().setMaster("local[*]").setAppName("sparkSQL");
        SparkSession spark = SparkSession.builder().config(conf).getOrCreate();

         Dataset<Row> df = spark.read().format("jdbc").option("url", "jdbc:mysql://127.0.0.1:3306/world")
                .option("driver", "com.mysql.jdbc.Driver").option("user", "root").option("password", "123123")
                .option("dbtable", "city").load();

         //df.select("Name").where(df.col("CountryCode") == "AFG").show();

    }
}
